package com.platform.enums;

import com.platform.comm.enums.IDictEntry;
import com.platform.comm.enums.IEnumItem;

import java.util.Arrays;
import java.util.Optional;

/**
 * description:
 *
 * @author zhangqian
 * @version v1.0
 * @date Created in 20210916
 */
public enum DsApplyStatus implements IDictEntry, IEnumItem {
    /**
     * 不通过
     */
    NOT_ADOPT(0, "未通过"),

    /**
     * 通过
     */
    ADOPT(1, "已通过"),

    /**
     * 待开发
     */
    DEVELOP(2, "待开发"),

    /**
     * 待审核
     */
    WAIT(3, "待审核"),

    /**
     * 已审批
     */
    ADOPT_PASSED(4, "已审批");

    private int code;
    private String text;

    DsApplyStatus(int code, String text) {
        this.code = code;
        this.text = text;
    }

    public static String getText(String code) {
        Optional<DsApplyStatus> optional = Arrays.stream(values()).filter(status -> status.getKey().equals(code)).findAny();
        return optional.isPresent() ? optional.get().getValue() : "";
    }

    @Override
    public boolean is(String code) {
        return this.name().equals(code);
    }

    @Override
    public String getKey() {
        return String.valueOf(code);
    }

    @Override
    public String getValue() {
        return text;
    }

    @Override
    public Object getData() {
        return this;
    }
}
